package org.veloxbot.api.wrappers;

import org.veloxbot.api.methods.Game;

import java.awt.Color;
import java.awt.Point;
import java.awt.Rectangle;

/**
 * @author Velox
 */
public class TColor {

	private final Color color;

	private final int defaultTolerance;

	private int tolerance;

	/**
	 * Constructs a class made up of a color and a tolerance.
	 *
	 * @param color     The color to search for.
	 * @param tolerance The tolerance of the color to search for.
	 */
	public TColor(final Color color, final int tolerance) {
		this.color = color;
		this.defaultTolerance = tolerance;
		this.tolerance = defaultTolerance;
	}

	/**
	 * Gets the constructed color.
	 *
	 * @return The constructed color.
	 */
	public Color getColor() {
		return color;
	}

	/**
	 * Sets the tolerance of the constructed color.
	 *
	 * @param tolerance The tolerance to set.
	 */
	public void setTolerance(final int tolerance) {
		this.tolerance = tolerance;
	}

	/**
	 * Gets the tolerance of the constructed color.
	 *
	 * @return The tolerance of the constructed color.
	 */
	public int getTolerance() {
		return tolerance;
	}

	/**
	 * Gets the original set tolerance.
	 *
	 * @return The original set tolerance.
	 */
	public int getDefaultTolerance() {
		return defaultTolerance;
	}

	/**
	 * Gets an array of points found relative to the constructor's parameters.
	 *
	 * @return An array of points found relative to the constructor's parameters.
	 */
	public Point[] findPoints() {
		return Game.getPointsWithColor(color, tolerance);
	}

	/**
	 * Gets an array of points within the given bounds relative to the constructor's parameters.
	 *
	 * @param bounds The bounds to search in.
	 * @return An array of points within the given bounds relative to the constructor's parameters.
	 */
	public Point[] findPoints(final Rectangle bounds) {
		return Game.getPointsWithColor(bounds, color, tolerance);
	}
}
